#include "heap.h"

void testHeap()
{
	printf("-------------testHeap-----------------\n");
	Heap hp ;
	HeapInit(&hp);

	HeapPush(&hp, 3);
	HeapPush(&hp, 5);
	HeapPush(&hp, 7);
	HeapPush(&hp, 2);
	HeapPush(&hp, 7);
	HeapPush(&hp, 4);
	HeapPush(&hp, 9);
	HeapPush(&hp, 16);
	HeapPush(&hp, 22);
	HeapPush(&hp, 3);

	printf("Top: %d\n", HeapTop(&hp)) ;

	HeapPop(&hp);
 	printf("Top: %d\n", HeapTop(&hp));

	HeapPop(&hp);
	printf("Top: %d\n", HeapTop(&hp));

	printHeap(&hp);

	HeapPush(&hp, 1);
	printHeap(&hp);

	printf("HeapSize: %d\n", HeapSize(&hp));
}

void printArry(HPDataType* a, int n)
{
	printf("Arry: ");
	for (int i = 0; i < n; ++i)
	{
		printf("%d ", a[i]);
	}
	printf("\n");
}

testHeaPSort()
{
	printf("-------------testHeapSort-----------------\n");
	HPDataType arry[] = { 3,9,4,5,1,9,7,7,64,187,6,14,3,0,8,4,9 };
	int n = sizeof(arry) / sizeof(arry[0]);
	HeapSort(arry, n-1);
	printArry(arry, n);
}

int main()
{
	//testHeap();
	testHeaPSort();
	return 0;

}